﻿using System;
using CommunityToolkit.Mvvm.ComponentModel;
using UI.ViewModels;

namespace UI.Models;

public partial class PlcInfo : ViewModelBase
{
    [ObservableProperty] private int _id;
    [ObservableProperty] private int _orderNum;
    [ObservableProperty] private string? _name;
    [ObservableProperty] private DateTime? _createdDate;
    [ObservableProperty] private DateTime? _modifiedDate;
    [ObservableProperty] private string? _cpuType;
    [ObservableProperty] private string? _ipAddress;
    [ObservableProperty] private int _rack;//机架号
    [ObservableProperty] private int _slot;//槽号
    [ObservableProperty] private int _timeout;
    [ObservableProperty] private int _status;
    [ObservableProperty] private bool _isChecked = false;

    public PlcInfo(){ }

    public PlcInfo(int id, int orderNum, string name, DateTime createdDate, DateTime modifiedDate, string cpuType, string ipAddress, int rack, int slot,int timeout)
    {
        _id = id;
        _orderNum = orderNum;
        _name = name;
        _createdDate = createdDate;
        _modifiedDate = modifiedDate;
        _cpuType = cpuType;
        _ipAddress = ipAddress;
        _timeout = timeout;
        _rack = rack;
        _slot = slot;
    }

    public string ShowStatus
    {
        get{
            if (Status == 0)
            {
                return "状态：已连接";
            }
            else
            {
                return "状态：已断开";
            }
        }
    }
    
    public string RackAndSlot
    {
        get
        {
            return $"机架号 {Rack} | 槽号 {Slot}";
        }
    }
    
    
}